<template>
  <div id="app">
    <van-tabbar route active-color="#CEA62A" v-if="flag">
      <van-tabbar-item replace to="/home" icon="home-o">首页</van-tabbar-item>
      <van-tabbar-item replace to="/topic" icon="coupon-o">专题 </van-tabbar-item>
      <van-tabbar-item replace to="/cartGory" icon="apps-o">分类</van-tabbar-item >
      <van-tabbar-item replace to="/cart" icon="shopping-cart-o">购物车</van-tabbar-item>
      <van-tabbar-item replace to="/user" icon="user-o">我的</van-tabbar-item>
    </van-tabbar>

    <keep-alive include="cartGory">
      <router-view></router-view>
    </keep-alive>
  
  </div>
</template>

<script>
export default {
  name: "user",
  data() {
    return {
      flag:false,
      active: 0,
      icon: {
        active: ".src/assets/tabberImg/cart.png",
        inactive: ".src/assets/tabberImgAct/cartA.png",
      },
      img:'./assets/ava.png'
    };
  },
  created(){
    var userInfo={
      openId:'1259990309',
      nickName:'小老虎',
      avatarUrl:this.img
    }
    var nickName=userInfo.nickName
    var openId=userInfo.openId
    localStorage.setItem('uerInfo',JSON.stringify(userInfo))
    localStorage.setItem('openId',openId)
    localStorage.setItem('nickName',nickName)


  },
  mounted() {},
  methods: {},
  watch:{
    "$route":function(to){
      var arr=['home','cart','cartGory','user','topic']
      if(arr.includes(to.name)){
        this.flag=true
      }else{
        this.flag=false
      }
    }
  }
};
</script>



<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  background-color: #f6f7f9;
  height: 100vh
}

nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
